<?php
/**
 * Reports listing js file.
 *
 * Handles javascript stuff related to reports list function.
 *
 * PHP version 5
 * LICENSE: This source file is subject to LGPL license 
 * that is available through the world-wide-web at the following URI:
 * http://www.gnu.org/copyleft/lesser.html
 * @author     Ushahidi Team <team@ushahidi.com> 
 * @package    Ushahidi - http://source.ushahididev.com
 * @module     API Controller
 * @copyright  Ushahidi - http://www.ushahidi.com
 * @license    http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL) 
 */
?>
		/*
		Toggle Layer Switchers
		*/
		function toggleLayer(link, layer, texto)
		{
			switch(texto)
			{
				case ("<?php echo Kohana::lang('ui_main.category'); ?>"):
				case ("<?php echo ucfirst(Kohana::lang('ui_main.days')); ?>"):
				case ("<?php echo Kohana::lang('ui_main.location'); ?>"):
			}
			if ($("#"+link).text() == "<?php echo Kohana::lang('ui_main.hide'); ?>")
			{
				$("#"+link).text('<?php echo Kohana::lang('ui_main.show'); ?>');
			}
			else
			{
				$("#"+link).text('<?php echo Kohana::lang('ui_main.hide'); ?>');
			}
			$('#'+layer).toggle(250);
		}							

		// jQuery Textbox Hints Plugin
		// Will move to separate file later or attach to forms plugin
		jQuery.fn.hint = function (blurClass) 
		{
		  if (!blurClass) { 
		    blurClass = 'texthint';
		  }

		  return this.each(function () {
		    // get jQuery version of 'this'
		    var $input = jQuery(this),

		    // capture the rest of the variable to allow for reuse
		      title = $input.attr('title'),
		      $form = jQuery(this.form),
		      $win = jQuery(window);

		    function remove() {
		      if ($input.val() === title && $input.hasClass(blurClass)) {
		        $input.val('').removeClass(blurClass);
		      }
		    }

		    // only apply logic if the element has the attribute
		    if (title) { 
		      // on blur, set value to title attr if text is blank
		      $input.blur(function () {
		        if (this.value === '') {
		          $input.val(title).addClass(blurClass);
		        }
		      }).focus(remove).blur(); // now change all inputs to title

		      // clear the pre-defined text when form is submitted
		      $form.submit(remove);
		      $win.unload(remove); // handles Firefox's autocomplete
			  $("#lnkFindLocation").click(remove);
              $("#lnkSend").click(remove);
		    }
		  });
		};
		
		$(document).ready(function() {
		  
		  // hover functionality for each report
		  $(".rb_report").hover(
		    function () {
          $(this).addClass("hover");
        }, 
        function () {
          $(this).removeClass("hover");
        }
		  );
		  
		  // category tooltip functionality
		  var $tt = $('.r_cat_tooltip');
		  $("a.r_category").hover(
		    function () {
		      // place the category text inside the category tooltip
		      $tt.find('a').html($(this).find('.r_cat-desc').html());
          // display the category tooltip
          $tt.css({
            'left': ($(this).offset().left - 6),
            'top': ($(this).offset().top - 27)
          }).show();
        }, 
        function () {
          $tt.hide();
        }
		  );
		});